<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Novel extends CI_Controller {
    
    function __construct() {
        parent::__construct();
        $this->load->model('novel_model');
    }
    
    public function index() {
        
    }
    
    public function get_novel_content_by_slug() {
        $slug = $this->uri->segment(2);
        $novel = $this->novel_model->getNovel_by_slug($slug);
        $novel->chapter = $this->novel_model->getNovelChapter_by_id($novel->id);
        $this->load->view('header', array('pageName' => 'pageNovel'));
        $this->load->view('novel', array('novel' => $novel));
        $this->load->view('sidebar');
        $this->load->view('footer');
    }
    
    public function get_chapter_content_by_id() {
        $slug = $this->uri->segment(2);
        $novel = $this->novel_model->getNovel_by_slug($slug);
        $novel->chapter = $this->novel_model->getNovelChapter_by_id($novel->id);
        
        $chapterId = $this->uri->segment(4);
        $chapter = $this->novel_model->getChapter_by_chapterId($novel->id, $chapterId);
        
        $this->load->view('header', array('fullview' => true, 'pageName' => 'pageChapter'));
        $this->load->view('chapter', array('novel' => $novel, 'chapter' => $chapter));
        $this->load->view('sidebar');
        $this->load->view('footer');
    }
    
    
}
